#pragma once
#include "IcmpReply.h"

#define UWM_PING_REPLY			(WM_USER + 1)
#define UWM_TRACEROUTE_REPLY	(WM_USER + 2)
#define UWM_WHOIS_REPLY			(WM_USER + 3)
#define UWM_LOOKUP_REPLY		(WM_USER + 4)
#define UWM_SCAN_REPLY			(WM_USER + 5)

class CIcmp
{
public:
	CIcmp(void);
	virtual ~CIcmp(void);
	void SetCallback(HWND hwndCallback);
	virtual LONG Ping(LPCTSTR lpszAddress);
	virtual LONG TraceRoute(LPCTSTR lpszAddress);

protected:
	virtual LONG _Ping(DWORD addr, ip_option_information* pOptionInfo, icmp_echo_reply* pReply);
	static UINT _DoPingThread(LPVOID pParam);
	virtual UINT _ExecutePingThread();
	static UINT _DoTraceRouteThread(LPVOID pParam);
	virtual UINT _ExecuteTraceRouteThread();
	virtual UINT _PostPingError();
	virtual UINT _PostTraceRouteError();

	CString m_sAddress;
	HANDLE m_hICmp;
	HWND m_hwndCallback;
	CIcmpReply m_oIcmpReply;
};
